class code2 {
    public int characterReplacement(String s, int k) {
        char[] ss = s.toCharArray();
        int left = 0;
        int right = 0;
        int[] hash = new int[26];
        int ret = 0;
        int MaxChar = 0;
        while(right < s.length()) {
            //进窗口
            hash[ss[right]-'A']++;
            //统计最大
            MaxChar = Math.max(MaxChar,hash[ss[right]-'A']);
            //判断
            while(right-left+1 > k+MaxChar) {
                hash[ss[left++]-'A']--;
            }
            //更新结果
            ret = Math.max(ret,right-left+1);
            right++;
        }
        return ret;
    }
}